<?

class Smutty_Controller_Smutty extends Smutty_Controller {

	/**
	 *  handles a request for a smutty resource
	 *
	 */

	function resourceAction( $data ) {

		Smutty_Main::loadClass( 'Smutty_Resource' );

		$path = 'library/public/' .
			$data->string('folder') . '/' .
			$data->string('file');

		if ( file_exists($path) )
			Smutty_Resource::output( $path, true );

	}

	/**
	 *  this method provides built-in syndication for all models
	 *
	 */

	function rssAction( $data ) {

		$class = $data->string( 'model' );
		$class = ucfirst( $class );

		if ( class_exists($class) ) {

			$model = new $class();
			if ( !$model->rss )
				new Smutty_Exception( 'rss not valid for model', 'SmuttySyndication' );

			eval( "\$models = $class::fetchAll(false,array(),10);" );

			$tpl = new Smutty_Template_Smutty();
			$tpl->assign( 'modelName', $class );
			$tpl->assign( 'model', $model );
			$tpl->assign( 'models', $models );

			$tpl->display( 'syndication/rss-2.0.tpl' );

		}

	}

}

?>